package com.mapbased.sfw.model;

import com.mapbased.sfw.component.StrRender;
import com.mapbased.sfw.component.XmlContext;
import com.mapbased.sfw.component.Xmlable;

public final class RenderGroup implements Renderable {

	final Renderable renders[];
	public   RenderGroup(Renderable[] rs){
		
		this.renders=rs;
	}

	@Override
	public void render(RenderContext ctx) {
		for (Renderable r : this.renders) {
			r.render(ctx);
		}

	}

	public void toXml(XmlContext xb) {
		for (Renderable r : this.renders) {
			if (r instanceof StrRender) {
				StrRender sr = (StrRender) r;
				xb.sb.append(sr.value);
				continue;
			}
			if (r instanceof Xmlable) {
				Xmlable x = (Xmlable) r;
				x.toXml(xb);

			} else
				throw new java.lang.RuntimeException(r.getClass()
						+ " is NOT xmlable!");
		}
	}

}
